package com.hutu.controller.biz.admin;

import com.hutu.model.resp.Response;
import com.hutu.service.biz.BaseProjectService;
import com.hutu.model.biz.BaseProject;
import javax.annotation.Resource;

import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;

import java.util.List;
import com.hutu.model.resp.ResponseVo;
/**
 * <p>
 *  Controller
 * </p>
 *
 * @author admin
 * @since 2024-05-10
 */
@RestController
@RequestMapping("/admin/base-project")
@Api(tags = "")
public class BaseProjectController {
    @Resource
    private BaseProjectService baseProjectService;

    @ApiOperation("新增")
    @PostMapping("/add")
    public ResponseVo add(@RequestBody BaseProject baseProject){
        return this.baseProjectService.add(baseProject);
    }

    @ApiOperation("逻辑删除")
    @DeleteMapping("/{id}")
    public ResponseVo delete(@PathVariable Integer id){
        return this.baseProjectService.deleteById(id);
    }

    @ApiOperation("批量逻辑删除")
    @DeleteMapping("/batch/{ids}")
    public ResponseVo deleteBatch(@PathVariable List<Integer> ids){
        return this.baseProjectService.deleteBatch(ids);
    }

    @ApiOperation("编辑更新")
    @PutMapping
    public ResponseVo edit(@RequestBody BaseProject baseProject){
        return this.baseProjectService.edit(baseProject);
    }

    @ApiOperation("查询")
    @GetMapping("/{id}")
    public ResponseVo findById(@PathVariable Integer id){
        return this.baseProjectService.findById(id);
    }

    @ApiOperation("分页条件查询")
    @PostMapping("/page")
    public ResponseVo list(@RequestParam(defaultValue = "1") Integer current,@RequestParam(defaultValue = "10") Integer size,String tableName){
        return this.baseProjectService.list(current,size,tableName);
    }

    @ApiOperation("下拉数据源")
    @GetMapping("/findDataForSelect")
    public ResponseVo findDataForSelect(){
        return Response.success(baseProjectService.findDataForSelect());
    }

}

